<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model common\models\Post */
/* @var $form yii\widgets\ActiveForm */
?>


<div class="post-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'content')->textarea(['rows' => 6]) ?>

    <?= $form->field($model, 'tags')->textarea(['rows' => 6]) ?>

   <!-- <?= $form->field($model, 'status')->textInput() ?> -->
   <!--方式一-->
   <!-- <?=$form->field($model,'status')
   ->dropDownList([1=>'草稿',2=>'已发布'],['prompt'=>'请选择状态']);?> -->
   
   <!--方式二-->
   <!--<?php
	$psObjs=\common\models\Poststatus::find()->all();
   $allStatus=\yii\helpers\BaseArrayHelper::map($psObjs,'id','name');
   ?>
   <?=$form->field($model,'status')
   ->dropDownList($allStatus,['prompt'=>'请选择状态']);?>-->
    <!--方式三-->
    <!--<?php
     $psArray=yii::$app->db->createCommand('select id,name from poststatus')->queryAll();
    $allStatus=\yii\helpers\BaseArrayHelper::map($psArray,'id','name');
    ?>
    <?=$form->field($model,'status')
        ->dropDownList($allStatus,['prompt'=>'请选择状态']);?>-->
    <!--方式四-->
    <!--<?php
    $allStatus = (new \yii\db\Query())
    ->select(['name','id'])
    ->from('poststatus')
    /*->where(['last_name' => 'Smith'])*/
    ->indexBy('id')
    ->column();
    ?>
    <?=$form->field($model,'status')
        ->dropDownList($allStatus,['prompt'=>'请选择状态']);?>-->
    <!--方式五-->
    <?php
    $allStatus = \common\models\Poststatus::find()
        ->select(['name','id'])
        /*->where(['last_name' => 'Smith'])*/
        ->indexBy('id')
        ->column();
    ?>
    <?=$form->field($model,'status')
        ->dropDownList($allStatus,['prompt'=>'请选择状态']);?>

    <!--<?= $form->field($model, 'create_time')->textInput() ?>

    <?= $form->field($model, 'update_time')->textInput() ?>-->

    <!--<?= $form->field($model, 'author_id')->textInput() ?>-->
    <?=$form->field($model,'author_id')
    ->dropDownList(
        \common\models\Adminuser::find()
            ->select(['nickname','id'])
            ->indexBy('id')
            ->column(),
        ['prompt'=>'请选择作者']
    );
    ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? '新增' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
